package cn.edu.sdjzu.xg2103.service;

import cn.edu.sdjzu.xg2103.dao.SchoolDao;
import cn.edu.sdjzu.xg2103.entity.School;

import java.sql.SQLException;

public class SchoolService {
    private static SchoolService schoolService = null;

    public static SchoolService getInstance(){
        //静态变量SchoolDao为null时，才创建SchoolDao对象
        //第二次或后来调用本方法就不指向null了，就不在创建对象。
        if (schoolService == null){
            schoolService = new SchoolService();
        }
        return schoolService;
    }
    public static School find(int id) throws SQLException {
        School school = SchoolDao.getInstance().find(id);
        return school;
    }
}
